<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.mongodb.client.MongoCursor,org.bson.Document,org.bson.types.ObjectId,java.util.Date" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>教师信息设置</title>
</head>
<body>
	<%
		//教师信息
		Document result = (Document)session.getAttribute("result"); 
	   	ObjectId _id = result.getObjectId("_id");
	  	String name = result.getString("name");
	  	String username = result.getString("username");
	  	String type = result.getString("type");
	  	String password = result.getString("password");
	  	String sex = result.getString("sex");
	  	String birthday = result.getString("birthday");
	  	String phone = result.getString("phone");
	  	String email = result.getString("email");
	  	String homephone = result.getString("homephone"); 
	  	String title = result.getString("title");
	  	String finaleducation = result.getString("finaleducation");
	    String finaleducationschool = result.getString("finaleducationschool");
	    String finaldegree = result.getString("finaldegree");
	    String finaldegreeschool = result.getString("finaldegreeschool");
	    String researchdirection = result.getString("researchdirection");  	
	%>
	<jsp:include page="navbar.jsp" />
	<div class="container-fluid">
		<div class="row mt20">
			<div class="col-md-2 col-md-offset-2">
				<div class="panel b">
					<div class="panel-heading bg-gray-lighter text-bold">个人资料</div>
	            	<div class="list-group">
	            		<a href="#tabSetting1" data-toggle="tab" class="list-group-item"><em class="fa fa-file mr-10"></em>基本信息</a>
	            		<a href="#tabSetting2" data-toggle="tab" class="list-group-item"><em class="fa fa-file mr-10"></em>其它信息</a>
	            		<a href="#tabSetting3" data-toggle="tab" class="list-group-item"><em class="fa fa-lock mr-10"></em>修改密码</a>                       	
	            	</div>
	        	</div>
	      	</div>
	      	<div class="col-md-6">
	        	<div class="tab-content p0 b0">
	            	<div id="tabSetting1" class="tab-pane active">
	               		<div class="panel">
                			<div class="panel-body">
                  				<h4 class="page-header mt0">基本信息</h4>
                  				<form name="basicinfoform" role="form" action="../common/profileServlet" method="post"  onsubmit="return checkbasic(this);" class="form-horizontal mt20">
	                  	    		<fieldset>
						              <div class="form-group">
						                  <label class="col-md-3 control-label">姓名</label>
						                  <div class="col-md-7">
						                     <input class="form-control" type="text" name="name" value="<%=name==null?"":name %>" placeholder="请输入教师姓名" />
						                  </div>
						               </div> 
					                </fieldset>
				               		<fieldset>
					               		<div class="form-group">
					                  		<label class="col-md-3 control-label">工号</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="username" value="<%=username %>" placeholder="请输入教师工号" readonly />
				                  			</div>
				               			</div>	
				               		</fieldset> 
				                	<fieldset>
					               		<div class="form-group">
					               			<label class="col-md-3 control-label">性别</label>
					               			<div class="col-md-7">
					               				<label class="radio-inline c-radio">
		                                 			<input id="inlineradio1" type="radio" name="sex" value="男" <%=sex.equals("男") ? "checked" : ""%>>
		                                 			<span class="fa fa-circle"></span>男</label>
		                        			 	<label class="radio-inline c-radio">
		                           					<input id="inlineradio2" type="radio" name="sex" value="女" <%=sex.equals("女") ? "checked" : ""%>>
		                           					<span class="fa fa-circle"></span>女</label>
					               			</div>
					               		</div>	
				               		</fieldset>  
				               		<fieldset>
				               			 <div class="form-group">
					                  		<label class="col-md-3 control-label">生日</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="date" name="birthday" value="<%=birthday==null?"":birthday %>" placeholder="请输入教师生日" />
				                  			</div>
				               			</div>
				               		</fieldset> 
				               		<fieldset>
						              <div class="form-group">
						                  <label class="col-md-3 control-label">职称</label>
						                  <div class="col-md-7">
						                     <input class="form-control" type="text" name="title" value="<%=title==null?"":title %>" placeholder="请输入教师职称" />
						                  </div>
						               </div> 
					                </fieldset>
				               		<fieldset>
					              		<div class="form-group">
					                  		<label class="col-md-3 control-label">家庭电话</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="homephone" value="<%=homephone==null?"":homephone %>" placeholder="请输入教师家庭电话" />
				                  			</div>
				               			</div>
				               		</fieldset> 
				               		<fieldset>
					              		<div class="form-group">
					                  		<label class="col-md-3 control-label">手机</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="phone" value="<%=phone==null?"":phone %>" placeholder="请输入教师手机" />
				                  			</div>
				               			</div>
				               		</fieldset>
				               		<fieldset>
					              		<div class="form-group">
					                  		<label class="col-md-3 control-label">邮箱</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="email" value="<%=email==null?"":email %>" placeholder="请输入教师邮箱" />
				                  			</div>
				               			</div>
				               		</fieldset>       
				               		<input type="hidden" name="_id" value="<%=_id %>" />
				               		<input type="hidden" name="type" value="<%=type %>" />
				               		<div class="col-md-10 col-md-offset-1">
				               			<div class="col-md-6">
				               				<button type="submit" class="btn btn-primary btn-block" name="method" value="update">确定</button> 
				               			</div>
				               			<div class="col-md-6">
				               				<button type="reset" class="btn btn-default btn-block">重置</button> 
				               			</div>
				               		</div>				               		
			              		</form>
		               		</div>
		            	</div>
		            </div>
	            	<div id="tabSetting2" class="tab-pane">
	               		<div class="panel">
                			<div class="panel-body">
                  				<h4 class="page-header mt0">其它信息</h4>
                				<form name="otherinfoform" role="form" action="../common/profileServlet" method="post" class="form-horizontal mt20">
	                  	    		<fieldset>
					               		<div class="form-group">
					                  		<label class="col-md-3 control-label">最后学历</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="finaleducation" value="<%=finaleducation==null?"":finaleducation %>" placeholder="请输入教师最后学历" />
				                  			</div>
				               			</div>	
				               		</fieldset> 
				                	<fieldset>
					               		<div class="form-group">
					                  		<label class="col-md-3 control-label">最后学历毕业院校</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="finaleducationschool" value="<%=finaleducationschool==null?"":finaleducationschool %>" placeholder="请输入教师最后学历毕业院校" />
				                  			</div>
				               			</div>
				               		</fieldset>  
				               		<fieldset>
				               			 <div class="form-group">
					                  		<label class="col-md-3 control-label">最后学位</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="finaldegree" value="<%=finaldegree==null?"":finaldegree %>" placeholder="请输入教师最后学位" />
				                  			</div>
				               			</div>
				               		</fieldset> 
				               		<fieldset>
					              		<div class="form-group">
					                  		<label class="col-md-3 control-label">最后学位毕业院校</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="finaldegreeschool" value="<%=finaldegreeschool==null?"":finaldegreeschool %>" placeholder="请输入教师最后学位毕业院校" />
				                  			</div>
				               			</div>
				               		</fieldset> 
				               		<fieldset>
					              		<div class="form-group">
					                  		<label class="col-md-3 control-label">研究方向</label>
				                  			<div class="col-md-7">
				                     			<input class="form-control" type="text" name="researchdirection" value="<%=researchdirection==null?"":researchdirection %>" placeholder="请输入教师研究方向" />
				                  			</div>
				               			</div>
				               		</fieldset>		
				               		<input type="hidden" name="_id" value="<%=_id %>" />
				               		<input type="hidden" name="type" value="<%=type %>" />		               			               		
				               		<div class="col-md-10 col-md-offset-1">
				               			<div class="col-md-6">
				               				<button type="submit" class="btn btn-primary btn-block" name="method" value="update">确定</button> 
				               			</div>
				               			<div class="col-md-6">
				               				<button type="reset" class="btn btn-default btn-block">重置</button> 
				               			</div>
				               		</div>				               		
		              			</form>
		               		</div>
		            	</div>
	              	</div>
	            	<div id="tabSetting3" class="tab-pane">
	               		<div class="panel">
                			<div class="panel-body">
                  				<h4 class="page-header mt0">修改密码</h4>
                  				<form name="passwordform" role="form" action="../common/profileServlet" method="post"  onsubmit="return checkpassword(this);" class="form-horizontal mt20">
	                  	    		<fieldset>
						            	<div class="form-group mt10">
						            		<label class="col-md-3 control-label">当前密码</label>
					                  		<div class="col-md-7">
					                     		<input class="form-control" type="password" name="nowPwd"  placeholder="请输入原始密码" />
					                  		</div>
						               	</div> 
					                </fieldset>
					                <fieldset>
						            	<div class="form-group mt10">
						            		<label class="col-md-3 control-label">新密码</label>
					                  		<div class="col-md-7">
					                     		<input class="form-control" type="password" name="newPwd" placeholder="新密码，密码长度6位以上" />
					                  		</div>
						               	</div> 
					                </fieldset>
					                <fieldset>
						            	<div class="form-group mt10">
						            		<label class="col-md-3 control-label">确认密码</label>
					                  		<div class="col-md-7">
					                     		<input class="form-control" type="password" name="newPwd2"  placeholder="请再一次输入密码" />
					                  		</div>
						               	</div> 
					                </fieldset>
					                <input type="hidden" name="_id" value="<%=_id %>">
					                <input type="hidden" name="password" value="<%=password %>">
					                <div class="col-md-10 col-md-offset-1">
				               			<div class="col-md-6">
				               				<button type="submit" class="btn btn-primary btn-block" name="method" value="changePwd">确定</button> 
				               			</div>
				               			<div class="col-md-6">
				               				<button type="reset" class="btn btn-default btn-block">重置</button> 
				               			</div>
				               		</div>	
					           </form>
                  			</div>
                  		</div>
                  	</div>
	            </div>
	      	</div>
	   </div>
	</div>
	<script type="text/javascript">  
	    //基本信息表单检验
	    function checkbasic(basicinfoform) {   
	    	var re = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	    	if(basicinfoform.name.value=="" || basicinfoform.name.value==null) {  
		        swal("姓名不能为空","请重新输入","warning");  
		        return false;  
		    } 
		    else if(basicinfoform.birthday.value=="" || basicinfoform.birthday.value==null) {  
		    	swal("生日不能为空","请重新输入","warning");   
		        return false;  
		    }  
		    else if(basicinfoform.title.value=="" || basicinfoform.title.value==null) {  
		   	    swal("职称不能为空","请重新输入","warning");   
		        return false;  
		    }
		    else if(basicinfoform.homephone.value=="" || basicinfoform.homephone.value==null) {  
		   	    swal("家庭电话不能为空","请重新输入","warning");   
		        return false;  
		    }
		    else if(basicinfoform.phone.value=="" || basicinfoform.phone.value==null) {  
		   	    swal("手机不能为空","请重新输入","warning");   
		        return false;  
		    }
		    else if(basicinfoform.email.value=="" || basicinfoform.email.value==null) {  
		   	    swal("邮箱不能为空","请重新输入","warning");   
		        return false;  
		    }else if(!re.test(basicinfoform.email.value)) {  
		   	    swal("邮箱格式有误","请重新输入","warning");   
		        return false;  
		    }
		    return true;   
	    }
	    
	    //修改密码表单检验
	    function checkpassword(passwordform) {   
	    	if(passwordform.nowPwd.value=="") {  
		        swal("当前密码不能为空","请重新输入","warning");  
		        return false;  
		    } 
		    else if(passwordform.newPwd.value==""||passwordform.newPwd.value.length<6) {  
		   	    swal("新密码长度大于6","请重新输入","warning");   
		        return false;  
		    }
		    else if(passwordform.newPwd.value!=passwordform.newPwd2.value) {  
		   	    swal("两次密码输入不相同","请重新输入","warning");   
		        return false;  
		    }
		    else if(passwordform.nowPwd.value!=passwordform.password.value) {  
		   	    swal("当前密码输入不正确","请重新输入","warning");   
		        return false;  
		    }
		    return true;   
	    }
	</script> 
</body>
</html>